package com.ruoyi.common.DataConversion;

import com.ruoyi.common.domin.TypeConvertUtils;
import struct.StructClass;
import struct.StructField;

import java.util.Date;

/**
 * @ClassName UpReadParamPackage
 * @Description 读参数上行包
 * @Author 张勇
 * @Date 2024-10-06
 * @Version 1.0.0.0
 **/
@StructClass
public class UpReadParamAllPackage {
    /**
     * 唯一码
     */
    @StructField(order = 0)
    public byte[] uniqueCode = new byte[2];

    /**
     * 结果
     */
    @StructField(order = 1)
    public byte[] result=new byte[1];


    /**
     * 地址
     */
    @StructField(order = 2)
    public byte[] address=new byte[2];

    /**
     * 数据长度
     */
    @StructField(order = 3)
    public byte[] dataLength = new byte[14];

    /**
     * 数据内容
     */
    @StructField(order = 4)
    public byte[] dataContent = new byte[4];

    /**
     * 接收时间
     */
    private Date receiveTime;

    /**
     * 获取上行唯一码
     *
     * @return
     */
    public String getUniqueCode() {
        return TypeConvertUtils.byteArrayToString(uniqueCode);
    }

    /**
     * 获取地址编号
     *
     * @return
     */
    public String getAddress() {
        return TypeConvertUtils.byteArrayReverseToString(address);
    }

    /**
     * 获取数据长度
     * @return
     */
    public int getDataLength() {
        return TypeConvertUtils.bytesToReverseInt(dataLength);
    }


    /**
     * 设置接收时间
     * @param receiveTime
     */
    public void setReceiveTime(Date receiveTime) {
        this.receiveTime = receiveTime;
    }

    /**
     * 获取接收时间
     * @return
     */
    public Date getReceiveTime() {
        return receiveTime;
    }

    public byte[] getResult() {
        return result;
    }

    public byte[] getDataContent() {
        return dataContent;
    }
}
